<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>分配菜单</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap-4.6.2-dist/css/bootstrap.css">
</head>
<body style="padding: 20px">

<h2>分配菜单 - ${role.name}</h2>

<form action="${pageContext.request.contextPath}/role/saveAssignedMenus" method="post">
    <input type="hidden" name="roleId" value="${role.id}">

    <div class="form-group">
        <label>选择菜单：</label>
        <div>
            <c:forEach items="${menus}" var="menu">
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" name="menuIds" value="${menu.id}"
                           <c:if test="${assignedMenuIds != null && assignedMenuIds.contains(menu.id)}">checked</c:if>>
                    <label class="form-check-label">${menu.name}</label>
                </div>
            </c:forEach>
        </div>
    </div>

    <button type="submit" class="btn btn-primary">保存分配</button>
    <a href="${pageContext.request.contextPath}/role/list" class="btn btn-secondary">返回</a>
</form>

</body>
</html>
